using TMPro;
using UnityEngine;

public class UiTooltip : MonoBehaviour
{
    [SerializeField] private float xLimit = 960f;
    [SerializeField] private float yLimit = 540f;
    [SerializeField] private float xOffset = -300f;
    [SerializeField] private float yOffset = 100f;

    protected virtual void AdjustPosition()
    {
        Vector2 mousePosition = Input.mousePosition;
        float newXOffset;
        float newYOffset;
        if (mousePosition.x > xLimit)
            newXOffset = -xOffset;
        else
            newXOffset = xOffset;
        if (mousePosition.y > yLimit)
            newYOffset = -yOffset;
        else
            newYOffset = yOffset;
        transform.position = new Vector3(mousePosition.x + newXOffset, mousePosition.y + newYOffset);
    }

    protected virtual void AdjustFontSize(TextMeshProUGUI textMeshProUGUI)
    {
        textMeshProUGUI.fontSize = textMeshProUGUI.text.Length > 12 ? 18 : 24;
    }
}
